/*
 * BncsPing.h
 *
 *  Created on: Nov 20, 2008
 *      Author: nathan
 */

#ifndef BNCSPING_H_
#define BNCSPING_H_

#include "BncsMessage.h"
#include "BncsMessageFactory.h"

class BncsPingData : public QSharedData
{
public:
	quint32 data;
};

class BncsPing : public BncsMessage
{
	BNCS_MESSAGE_REGISTER(BncsPing, 0x25);

public:
	QSharedDataPointer<BncsPingData> d;

public:
	quint32 id()
	{
		return id;
	}

	int size()
	{
		return sizeof(d->data);
	}

	void readFrom(QDataStream& ds)
	{
		int bo = ds.byteOrder();
		ds.setByteOrder(QDataStream::LittleEndian);

		ds >> d->data;

		ds.setByteOrder((QDataStream::ByteOrder)bo);
	}

	void writeTo(QDataStream& ds)
	{
		int bo = ds.byteOrder();
		ds.setByteOrder(QDataStream::LittleEndian);

		ds << d->data;

		ds.setByteOrder((QDataStream::ByteOrder)bo);
	}
};

#endif /* BNCSPING_H_ */
